﻿using CommonLibrary;
using CommonSite.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace CommonSite.Areas.API.Controllers
{
    public class BaseAPIController : Controller
    {
        protected ActionResult Success() 
        {
            return Content(APIResult.Success, "application/json");
        }

        protected ActionResult Success(object result)
        {
            return Content(JSON.ToString(result), "application/json");
        }

        protected ActionResult ArgumentFailed()
        {
            return Content(APIResult.ArgumentFailed, "application/json");
        }

        protected ActionResult Failed()
        {
            return Content(APIResult.Create("发生未知错误"), "application/json"); 
        }

        protected ActionResult Failed(string error)
        {
            return Content(APIResult.Create(error), "application/json");
        }
    }
}
